package demo2;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-08-08
 * Time: 12:05
 */
public class TestDemo3 {

    public static void main(String[] args) throws FileNotFoundException {
        try(InputStream inputStream = new FileInputStream("text.txt")){
            byte[] bytes = new byte[1024];
            int len = inputStream.read(bytes);
            String s = new String(bytes,0,len,"utf8");
            System.out.println(s);
            inputStream.close();
        }catch (IOException e) {
            e.printStackTrace();
        }
    }

}
